package com.assets.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.assets.R;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/4/27.
 */

public class Service_Adapter extends BaseAdapter {
    private List<Map<String, Object>> data;
    private LayoutInflater layoutInflater;
    private Context context;
    public Service_Adapter(Context context, List<Map<String, Object>> data){
        //传入的data，就是我们要在listview中显示的信息
        this.context = context;
        this.data = data;
        this.layoutInflater = LayoutInflater.from(context);
    }
    public class Info {
        public TextView maintainId;//单号
        public TextView part;//零件
        public TextView remark;//备注
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Service_Adapter.Info info = new Service_Adapter.Info();
        convertView = layoutInflater.inflate(R.layout.service_adapter, null);
        info.maintainId = (TextView) convertView
                .findViewById(R.id.maintainId);
        info.part = (TextView) convertView
                .findViewById(R.id.part);
        info.remark = (TextView) convertView
                .findViewById(R.id.remark);
        //设置数据
        info.maintainId.setText((String) data.get(position).get(
                "maintainId"));
        info.part.setText((String) data.get(position).get(
                "part"));
        info.remark.setText((String) data.get(position)
                .get("remark"));
        return convertView;
    }
}
